import os
import cv2
import numpy as np

dir = './'

lst_imgs = os.listdir(dir)
for img_file in lst_imgs:
	if img_file.split('.')[-1] == 'jpg':
		img = cv2.imread(dir + img_file, cv2.IMREAD_GRAYSCALE)

		# 旋转90°
		img2 = np.rot90(img)
		img_file2 = img_file.split('.')[0] + '_2' + '.jpg'
		cv2.imwrite(dir + img_file2, img2)

		# 上下flip
		img3 = cv2.flip(img, 0)
		img_file3 = img_file.split('.')[0] + '_3' + '.jpg'
		cv2.imwrite(dir + img_file3, img3)

		# 左右flip
		img4 = cv2.flip(img2, 1)
		img_file4 = img_file.split('.')[0] + '_4' + '.jpg'
		cv2.imwrite(dir + img_file4, img4)
